package com.ctrip.ec.api.mobile.service.job;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

/**
 * Created by jiangzy on 2018/11/13.
 */
@Service
public class JobService {
    private static final ScheduledExecutorService pool = Executors.newScheduledThreadPool(4);
    private static final Logger logger = LoggerFactory.getLogger(JobService.class);

    @Autowired
    private ActivityJob activityJob;

    @Autowired
    private CartJob cartJob;

    @PostConstruct
    public  void init() {

        logger.info("activityJob  start");
        pool.scheduleAtFixedRate(activityJob, 0, 5, TimeUnit.SECONDS);

        logger.info("cartJob start");
        pool.scheduleAtFixedRate(cartJob,0,5,TimeUnit.SECONDS);
    }
}
